#ifndef USERMANAGER_H
#define USERMANAGER_H

#include <QWidget>
#include "tableView/tableviewheader.h"
#include <QStandardItemModel>


namespace Ui {
class UserManager;
}
typedef  struct USERINFO_TABLE_DATA_T
{
    QString UserID;//用户编号
    QString UserName;//用户名
    QString UserPWD;//用户密码
    QString UserSex;//用户性别
    QString UserAge;//用户年龄

}USERINFO_TABLE_DATA;

typedef QHash<QString, USERINFO_TABLE_DATA> QHashUserInfoTable;
typedef QHash<QString, USERINFO_TABLE_DATA>::iterator QHashUserInfoTableIterator;
class UserManager : public QWidget
{
    Q_OBJECT
    enum COLUMN_USERINFO
    {
        COLUMN_CHECKBOX = 0,
        COLUMN_NO,
        COLUMN_ID,
        COLUMN_NAME,
        COLUMN_PWD,
        COLUMN_SEX,
        COLUMN_AGE

    };

public:
    explicit UserManager(QWidget *parent = nullptr);
    ~UserManager();
    void paintEvent(QPaintEvent *event);
    void initTableView();
    void setColumnWidth();
    void resizeEvent(QResizeEvent *);
    void RefreshTable();

private slots:
    void on_usermanager_pushButton_selectfile_clicked();
    void on_tableViewClick(QModelIndex nIndex);
    void on_tableViewDbClick(QModelIndex nIndex);
    void on_tableViewSort(int nColumn);
    void on_tableViewSelectAllCheckBoxClick(Qt::CheckState state);


    void on_pushButton_exit_clicked();

    void on_usermanager_pushButton_input_clicked();

    void on_usermanager_pushButton_delete_clicked();

    void on_usermanager_pushButton_query_clicked();

    void on_usermanager_pushbutton_update_clicked();

    void getUpdateInfo(bool b);

private:
    Ui::UserManager *ui;
    QStandardItemModel *m_pTableModel;
    TableViewHeader *m_pTableHeader;
    int m_nCheckedCount;//选中个数
    QHashUserInfoTable m_userInfoTableHash;
signals:
    void sendUserID(QString userid);
};

#endif // USERMANAGER_H
